package org.terrier.matching.models.scorefitting;
import org.terrier.structures.*;
import org.terrier.applications.*;

public class GetParameter{
	int N;//ÎÄŒþµÄÊýÁ¿
	Index index = null;
	public GetParameter(){
		
		//String[] terrierhome = {"D:\\IR-test\\terrier-3.0"};
		//TrecTerrier.main(terrierhome);
		//TRECSetup.main(terrierhome);
		index = Index.createIndex();
		CollectionStatistics cs = index.getCollectionStatistics();
		N = cs.getNumberOfDocuments(); // ÎÄµµÊýÁ¿
	}
	public int[] GetDocLength(){
		//Index index = null;
		//index = Index.createIndex();
		int[] DocLength = new int[N];//ÎÄµµµÄ³€¶È
		DocumentIndex di = index.getDocumentIndex();
		try{
		for (int i=0; i<N; i++)
			DocLength[i] = di.getDocumentLength(i);
		}catch(Exception e){
			e.printStackTrace();
		}
		return DocLength;
	}
	public int[][] GetTf(String term){
		Lexicon lexicon = index.getLexicon();
		LexiconEntry lexEntry = lexicon.getLexiconEntry(term);
		int[][] DocTf = index.getInvertedIndex().getDocuments(lexEntry);
		return DocTf;
	}
	public int GetN(){
		return N;
	}
}